package com.example.demo.task;

import com.example.demo.service.DemoTaskServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


//定时任务
@Slf4j
@Component
@EnableScheduling
public class DemoTask {

    @Autowired
    DemoTaskServer demoTaskServer;



//    @Scheduled(cron = "0/10 * * * * ? ")
    public void testSchedule() throws Exception {
        log.info("当前执行任务的线程号ID===>{}", Thread.currentThread().getId()); // 日志输出
        demoTaskServer.insertData();;
    }

}
